package com.example.demo.service.impl;

import com.example.demo.mapper.GoodsMapper;
import com.example.demo.pojo.Dto.GoodsDto;
import com.example.demo.pojo.Goods;
import com.example.demo.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.tomcat.util.http.fileupload.util.LimitedInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Resource
    private GoodsMapper goodsMapper;

    @Override
    public Goods selectGoodsById(Integer id) {
        return goodsMapper.selectGoodsById(id);
    }

    @Override
    public List<GoodsDto> selectGoodsByParam(String pro) {
        return goodsMapper.selectGoodsByParam(pro);
    }

    @Override
    public PageInfo<List<GoodsDto>> selectByName(String name, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<GoodsDto> list=goodsMapper.selectByName(name);
        PageInfo<List<GoodsDto>> pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<GoodsDto> selectClassify(int id, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<GoodsDto> list=goodsMapper.selectClassify(id);
        PageInfo<GoodsDto> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }


}
